"""
    日志分别连接到阿里云正式、测试和console
"""
import logging
# from aliyun.log import QueuedLogHandler
# from aliyun.log.logger_hanlder import SimpleLogHandler
from app.conf import RUN_CONFIG


logger = logging.getLogger('default')
logger_script = logging.getLogger('script')
logger_scheduler = logging.getLogger('scheduler')
logger_web_access = logging.getLogger('access_log')


# def get_handler(log_store, extra=False):
#     handler = QueuedLogHandler(
#         end_point=RUN_CONFIG.ALIYUN_LOG_ENDPOINT,
#         access_key_id=RUN_CONFIG.ALIYUN_LOG_ACCESSID,
#         access_key=RUN_CONFIG.ALIYUN_LOG_ACCESSKEY,
#         project=RUN_CONFIG.LOGGING_PROJECT,
#         log_store=log_store
#     )
#     if extra:
#         handler.extract_json = True
#         handler.extract_json_drop_message = True
#         handler.extract_json_prefix = "invest_"
#     return handler


# def get_simple_handler(log_store):
#     return SimpleLogHandler(
#         end_point=RUN_CONFIG.ALIYUN_LOG_ENDPOINT,
#         access_key_id=RUN_CONFIG.ALIYUN_LOG_ACCESSID,
#         access_key=RUN_CONFIG.ALIYUN_LOG_ACCESSKEY,
#         project=RUN_CONFIG.LOGGING_PROJECT,
#         log_store=log_store
#     )


formatter_msg = logging.Formatter('%(asctime)s %(filename)s[line:%(lineno)d] [%(levelname)s] (%(threadName)-10s) %(message)s')
console_handler = logging.StreamHandler()
console_handler.setFormatter(formatter_msg)


# handler_aliyun_default = get_handler('default', extra=True)
logger.setLevel(logging.INFO)
# logger.addHandler(handler_aliyun_default)
logger.addHandler(console_handler)
logger_script.addHandler(console_handler)
# handler_aliyun_scheduler = get_handler('scheduler')
# logger_scheduler.addHandler(handler_aliyun_scheduler)
logger_scheduler.addHandler(console_handler)
# logger_web_access.addHandler(get_handler('access_log'))
